#include "rssplugin.h"
#include "preview.h"
#include "settings.h"

RSSPlugin::RSSPlugin()
{
    prev = 0;
    settingsW = 0;
    m_icon = QPixmap(QString::fromUtf8(":/icon/res/icon.jpg"));
}

RSSPlugin::~RSSPlugin()
{
    //if(prev!=0)
        //delete prev;
    if(settingsW!=0)
        delete settingsW;
}

QString RSSPlugin::name()
{
    return QString("RSS plugin");
}

QPixmap RSSPlugin::icon(int h, int w)
{
    if(h>0 && w>0)
        return m_icon.scaledToHeight(h).scaledToWidth(w);
    else
        return m_icon;
}

QWidget* RSSPlugin::widgetFor(PLUGIN_TYPE type, QWidget *parent)
{
    if(prev!=0)
        delete prev;
    prev = new Preview(parent);
    return prev;
}

QWidget* RSSPlugin::settings()
{
    if(settingsW!=0)
        delete settingsW;
    settingsW = new Settings(0);
    if(settingsW==0)
        qDebug("Settings widget is null...");
    return settingsW;
}

Q_EXPORT_PLUGIN2(RSS, RSSPlugin)
